
#include "help.hpp"
using namespace std;

class Solution
{
    vector<vector<int>> mGrid;
    int m, n;

public:
    int minPathSum(vector<vector<int>> &grid)
    {
        mGrid = grid;
        m = grid.size();
        n = grid[0].size();
        return minpath(0, 0);
    }
    // x,y 到目标点的距离
    int minpath(int x, int y)
    {
        if (x == m - 1 && y == n - 1)
        {
            return mGrid[x][y];
        }
        else if (x == m - 1)
        {
            return minpath(x, y + 1) + mGrid[x][y];
        }
        else if (y == n - 1)
        {
            return minpath(x + 1, y) + mGrid[x][y];
        }
        else
        {
            return min(minpath(x, y + 1), minpath(x + 1, y)) + mGrid[x][y];
        }
    }
};
int main(int argc, char const *argv[])
{
    std::cout << "hello" << std::endl;
    Solution s;
    vector<vector<int>> grid = parseNestedIntVectorString("[[1,3,1],[1,5,1],[4,2,1]]");
    int result = s.minPathSum(grid);

    return 0;
}
